package com.org.redis.redisson;

import org.redisson.Redisson;
import org.redisson.config.Config;
import org.redisson.config.TransportMode;

/**
 * 构建redis的方法
 */
public class RedissonConfig {

    //程序化配置  + 单redis
    public static Redisson create1(){
        Config config = new Config();
        config.useSingleServer().setAddress("redis://127.0.0.1:6379")
                .setDatabase(15);
        return (Redisson) Redisson.create(config);
    }

    /**
     * 集群模式
     * @return
     */
    public static Redisson create2(){
        Config config = new Config();
        config.setTransportMode(TransportMode.EPOLL)
                .useClusterServers()
                .setScanInterval(2000)//集群状态扫描时间，单位为毫秒
                .addNodeAddress("redis://127.0.0.1:6379","redis://127.0.0.1:6380","redis://127.0.0.1:6381");
        return (Redisson) Redisson.create(config);
    }


}
